package org.ala.tiktools.client_server.bean;

import java.lang.reflect.Method;
import java.util.Map;

import org.ala.tiktools.logs.LoggerFactory;
import org.ala.tiktools.rpc.plugin.interceptor.IRpcInterceptor;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

/**
 *
 *	@author ala
 *	@date 2025年5月2日
 */
@Component
public class ReceiverInterceptor implements IRpcInterceptor {
	static Logger log = LoggerFactory.getLogger("rpc", "receiver");
	
	@Override
	public void doIntercept(Method method, Object[] args, Map<String, Object> metadata) throws Exception {
		log.info("接收端前置拦截 metadata:{}", metadata);
	}
	@Override
	public void afterIntercept(Method method, Object[] args, Object res, Map<String, Object> metadata) throws Exception {
		log.info("接收端后置拦截 把aaaa的值 * 10");
		Integer v = (Integer) metadata.get("aaaa");
		metadata.put("aaaa", v * 10);
	}
	@Override
	public int sort() {
		return 0;
	}
}
